import type { TextProps, OptionsProps, PicLink, Status } from '@/types';
// 题目类型
export type SurveyComName =
  | 'single-select'
  | 'multi-select'
  | 'option-select'
  | 'single-pic-select'
  | 'multi-pic-select'
  | 'text-input'
  | 'rate-score'
  | 'date-time'
  | 'personal-info-name'
  | 'personal-info-id'
  | 'personal-info-birth'
  | 'personal-info-gender'
  | 'personal-info-age'
  | 'personal-info-education'
  | 'personal-info-collage'
  | 'personal-info-major'
  | 'personal-info-industry'
  | 'personal-info-career'
  | 'personal-info-company'
  | 'personal-info-position'
  | 'personal-info-tel'
  | 'personal-info-wechat'
  | 'personal-info-qq'
  | 'personal-info-email'
  | 'personal-info-address';

// 业务组件类型(题目类型 + 非题目类型)
export type Material = SurveyComName | 'text-note';

export interface Actions {
  setTextStatus: (textProps: TextProps, text: string) => void;
  addOption: (optionsProps: OptionsProps) => void;
  removeOption: (optionsProps: OptionsProps, index: number) => number;
  setOption: (optionsProps: OptionsProps, option: number) => void;
  setPicLinkByIndex: (optionsProps: OptionsProps, picLink: PicLink) => void;
  setIsUse: (optionsProps: OptionsProps, flag: boolean) => void;
  setRateScoreText: (optionsProps: OptionsProps, object: { val: string; index: number }) => void;
}

// 仓库状态
export interface MaterialStore extends Actions {
  currentMaterialCom: Material;
  coms: Record<Material, Status>;
  // setCurrentSurveyCom: (com: Material) => void;
  setCurrentMaterialCom: (comName: string) => void;
}

// 记录题目类型的数组
const SurveyComNameArr = [
  'single-select',
  'multi-select',
  'option-select',
  'single-pic-select',
  'multi-pic-select',
  'text-input',
  'rate-score',
  'date-time',
  'personal-info-name',
  'personal-info-id',
  'personal-info-birth',
  'personal-info-gender',
  'personal-info-age',
  'personal-info-education',
  'personal-info-collage',
  'personal-info-major',
  'personal-info-industry',
  'personal-info-career',
  'personal-info-company',
  'personal-info-position',

  'personal-info-tel',
  'personal-info-wechat',
  'personal-info-qq',
  'personal-info-email',
  'personal-info-address',
];
export function isSurveyComName(value: string): value is SurveyComName {
  return SurveyComNameArr.includes(value);
}

const unsupportedPDFComNameArr = [
  'option-select',
  'rate-score',
  'date-time',
  'personal-info-birth',
];
export function canUsedForPDF(value: string) {
  return !unsupportedPDFComNameArr.includes(value);
}
